home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-15 | 4.6 KB | 214 lines | [TEXT/MPS ] |
- ; Copyright © Apple Computer Inc.
- ; UDebug assembly language routines
-
- Blanks On
- String AsIs
- Case On
-
- Print Off
- Include 'Macros.a'
-
- Include 'IntEnv.a'
- Include 'ProgStrucMacs.a'
- Include 'FlowCtlMacs.a'
-
- Print On
-
- ;---------------------------------------------------------------------------------------------------
- DebugGlobals Record
- Export pCanEnterDebugger, pUDebugInitialized, pSegTable
- pCanEnterDebugger DC.W 0 ; Boolean: Debugger can be entered
- pUDebugInitialized DC.W 0 ; Boolean: if Trace unit is inited
- pSegTable DC.L 0 ; HandleListHandle
- EndR ; Too bad Pascal doesn't have initialization
-
-
- ;---------------------------------------------------------------------------------------------------
- DevGlobals Record
- Export PFILENAME
- pPutProc DC.L 0 ; Address of the PASCAL Proc to Handle WriteLn requests
- ; Procedure DEVPUTTEXT(textBuf: Ptr, byteCount: longint);
- pGetProc DC.L 0 ; Address of the PASCAL Proc to Handle Read requests
- ; Function DEVGETTEXT(textBuf: Ptr, byteCount: longint): longint;
-
- PFILENAME DCB.B 256,0 ; FileName to intercept for console
- EndR
-
-
- ;-----------------------------------------------------------------------------------
- ;int DevFAccess(fName, cmd, arg)
- ; char *fName;
- ; int cmd;
- ; char *arg;
- ;{
- ;# define IgnoreCase false
- ;# define DiacritSens true
- ;
- ;/*
- ; if ((equalstring(fName, PFILENAME, false, true)))
- ;*/
- ; switch (cmd) {
- ; default:
- ; return(-1);
- ; case F_OPEN:
- ; return(0);
- ; }
- ;/*
- ; else
- ; return(-1);
- ;*/
- ;}
- F_OPEN EQU (('d'<<8)|00) ; for internal use only. Use only as directed.
- Seg 'Main'
- EXPORT FUNCTION DevFAccess(fName:L, cmd:L, arg:L):L,C
- BEGIN SAVE=D2/D3,WITH=DevGlobals
- Import EQUALSTRING, P2CSTRPROC, C2PSTRPROC ; library routines
- MOVE.L cmd(FP),D3
- Call C2PSTRPROC(fName(FP):L);
- LEA PFILENAME,A0
- Call EQUALSTRING:B(fName(FP):L, A0:L, #0:B, #1:B),D2
- Call P2CSTRPROC(fName(FP):L);
- IF# D2 NE.B #0 THEN.S
- Switch# D3
-
- Case#.S F_OPEN
- MOVEQ #0,D0
- Leave#.S
- Default#
- MOVEQ #-1,D0
-
- EndS#
- ELSE#.S
- MOVEQ #-1,D0
- ENDIF#
-
- RETURN
- EndF
-
-
- ;-----------------------------------------------------------------------------------
- ;int DevClose()
- ;{
- ; return(0);
- ;}
-
- Seg 'Main'
- EXPORT FUNCTION DevClose:L,C
- BEGIN
- MOVEQ #0,D0
- Return
- EndF
-
-
- ;-----------------------------------------------------------------------------------
-
- Seg 'Main'
- EXPORT FUNCTION SETGETPROC(theGetProc:L):L
- BEGIN with=DevGlobals
- MOVE.L pGetProc,SETGETPROC(FP)
- MOVE.L theGetProc(FP), pGetProc
- Return
- EndF
-
- ;-----------------------------------------------------------------------------------
-
- Seg 'Main'
- EXPORT FUNCTION SETPUTPROC(thePutProc:L):L
- BEGIN with=DevGlobals
- MOVE.L pPutProc,SETPUTPROC(FP)
- MOVE.L thePutProc(FP), pPutProc
- Return
- EndF
-
-
- ;-----------------------------------------------------------------------------------
- ;int DevRead(iop)
- ; IOPort *iop;
- ;{
- ; int bytesRead;
- ;
- ; bytesRead = DevReadLn(iop->inQ.bufp, iop->inQ.count);
- ; iop->inQ.bufp += bytesRead;
- ; iop->inQ.count -= bytesRead;
- ; return(0);
- ;}
-
- Seg 'Main'
- EXPORT FUNCTION DevRead(iop:L):L,C
- BEGIN with=DevGlobals,SAVE=D2/A2
-
- MOVE.L iop(FP),A2
-
- ; CALL (pGetProc):L($10(A2):L,$0E(A2):W),D0
- MOVE.L pGetProc, A0
- CLR.L -(SP) ;make room for function result
- MOVE.L $10(A2), -(SP)
- MOVE.W $0E(A2), -(SP)
- JSR (A0)
- MOVE.L (SP)+,D0
-
- ADD.L D0,$10(A2) ;add it to bufp
- SUB.L D0,$0C(A2) ;sub it from count
- MOVEQ #0,D0 ;Return value
- RETURN
- ENDF
-
-
- ;-----------------------------------------------------------------------------------
- ;int DevWrite(iop)
- ; IOPort *iop;
- ;{
- ; DevAddText(iop->inQ.bufp, iop->inQ.count);
- ;
- ; return(0);
- ;}
-
- Seg 'Main'
- EXPORT FUNCTION DevWrite(iop:L):L,C
- BEGIN with=DevGlobals,SAVE=D2/A2
-
- MOVE.L iop(FP),A2
-
- ; CALL (pPutProc)($10(A2):L,$0E(A2):W)
- MOVE.L pPutProc, A0
- MOVE.L $10(A2), -(SP)
- MOVE.W $0E(A2), -(SP)
- JSR (A0)
-
- CLR.L $0C(A2)
- MOVEQ #0,D0 ;Return Value
- RETURN
- ENDF
-
- ;-----------------------------------------------------------------------------------
- ;int DevIoctl(iop, cmd, arg)
- ; IOPort *iop;
- ; int cmd;
- ; char *arg;
- ;{
- ; switch (cmd) {
- ; case FIOINTERACTIVE:
- ; case TIOFLUSH:
- ; return(0);
- ; default:
- ; return(-1);
- ; }
- ;}
- Seg 'Main'
- EXPORT FUNCTION DevIoctl(iop:L, cmd:L, arg:L):L,C
- BEGIN
- Switch# cmd(FP)
-
- Case#.S FIOINTERACTIVE,TIOFLUSH
- MOVEQ #0,D0 ;Return Value
- Leave#.S
-
- Default#
- MOVEQ #-1,D0 ;Return Value
- EndS#
-
- RETURN
- EndF
-
- End
-